#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

int n;
vector<pair<int, int>> pts;
vector<vector<double>> dis;
vector<int> path;
vector<int> bestv;
double best = 0;

void genData(int n) {
    ::n = n;
    pts.resize(n);
    for (int i = 0; i < n; i++) {
        pts[i] = make_pair(rand() % (10 * n), rand() % (10 * n));
    }
    sort(pts.begin(), pts.end());
    dis.resize(n);
    for (int i = 0; i < n; i++) {
        dis[i].resize(n);
        for (int j = 0; j < n; j++) {
            dis[i][j] = hypot(pts[i].first - pts[j].first, pts[i].second - pts[j].second);
        }
    }
    cout << n << endl;
    for (auto pt:pts) {
        cout << pt.first << " " << pt.second << endl;
    }
    for (int i = 0; i < n; i++) {

        for (int j = 0; j < n; j++) {
            cout << " " << fixed << setprecision(2) << dis[i][j];
        }
        cout << endl;
    }
}

double eval(vector<int> &path) {
    double s = 0;
    for (int i = 0; i < n; i++) {
        s += dis[path[i]][path[(i + 1) % n]];
    }
    return s;
}

void solve() {
    path.resize(n);
    for (int i = 0; i < n; i++)path[i] = i;
    best = INT_MAX;
    for (int i = 0; i < 100000; i++) {
        random_shuffle(path.begin(), path.end(),[](int x){
            return rand()%x;
        });
        if (eval(path) < best) {
            bestv = path;
            best = eval(path);
        }
    };
    for (int i = 0; i < n; i++) {
        cout << bestv[i] << " ";
    }
    cout << endl;
    cout << best << endl;

}

int main() {
    //srand(time(NULL));
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    genData(10);
    solve();
    return 0;
}
